<#include "../base.ftl"/>
<#macro cssfile>
</#macro>

<#macro scriptfile>
</#macro>

<#macro breadcrumb>
    <ul class="breadcrumb">
     <#include "../crumb.ftl"/>
     <li class="active">动态跟踪</li>
    </ul>
</#macro>

<#macro title>
广大物流云平台
</#macro>
<#macro jsscript>
     var setting = {
            async: {
                enable: true,
                url: '${request.contextPath}/admin/shipVoyageTree.action',
                datatype : 'json',
                autoParam:["id","name","level","flag"]
            },
            data: {
                simpleData: {
                       enable: true
                }
            },
            callback:{
                onNodeCreated : zTreeonNodeCreated,
                onClick:zTreeClick
            }
            
        };
 
    function zTreeClick(event,treeId,treeNode){
    alert(treeNode.flag);
        var a=treeNode.id;
          //alert(a);
          a=a.replace("C","");
          
        //alert(a);
            jQuery("#gridTable").jqGrid('setGridParam',{
                url : "${request.contextPath}/list!list.action?voyageId="+a,
                page : 1 
            });
            jQuery("#gridTable").trigger('reloadGrid');
        }
        function zTreeonNodeCreated(event,treeId,treeNode){
        var treeObj=$.fn.zTree.getZTreeObj(treeId);
        var list=treeObj.getNodeByParam("level",'1');
        treeObj.expandNode(list,true,true,true);
     
     
     }

        jQuery(document).ready(function(){
            $.fn.zTree.init($("#shipTree"), setting);
        });
        
$(function(){
    $("#gridTable").jqGrid({
    //list表格获取地址
        //list表格数据获取地址
        url:'${request.contextPath}/list!list.action',
        //list表格编辑地址
        editurl :'${request.contextPath}/operator.action',
        datatype: "json",
        mtype:"POST",
        height: 200,
        colNames:['动态编号','航次编码','动态名称','港口','计划时间','实际时间','备注','状态','创建人','创建日期','最后修改人','最后修改时间'],
        colModel:[
            {name:'dynamicId',jsonmap:'DYNAMIC_ID',index:'DYNAMIC_ID',editable:false,hidden:true},          
            {name:'voyageId',jsonmap:'VOYAGE_ID',index:'VOYAGE_ID',editable:false},     
            {name:'dynamicName',jsonmap:'DYNAMIC_NAME',editable:true,index:'DYNAMIC_NAME'},      
            {name:'port',jsonmap:'PORT',editable:true,index:'PORT'},
            {name:'planTime',jsonmap:'PLAN_TIME',editable:false,index:'PLAN_TIME',
                  editoptions :  {dataInit: function(element) {
                    $(element).datepicker({changeMonth : true,changeYear : true,dateFormat : 'yy-mm-dd'});
                }}     
            },
            {name:'realTime',jsonmap:'REAL_TIME',index:'REAL_TIME',editable:false,
                  editoptions :  {dataInit: function(element) {
                    $(element).datepicker({changeMonth : true,changeYear : true,dateFormat : 'yy-mm-dd'});
                }}     
             
            },
            {name:'remark',jsonmap:'REMARK',index:'REMARK',editable:false},
            {name:'status',jsonmap:'STATUS',index:'STATUS',editable:false,hidden:true,
              
            },
            {name:'createdBy',jsonmap:'CREATED_BY',editable:false,hidden:true},
            {name:'createdDate',jsonmap:'CREATED_DATE',editable:false,hidden:true,
                editoptions :  {dataInit: function(element) {
                    $(element).datepicker({changeMonth : true,changeYear : true,dateFormat : 'yy-mm-dd'});
                }}       
            },
            {name:'lastUpdBy',jsonmap:'LAST_UPD_BY',editable:false,hidden:true},
            {name:'lastUpdDate',jsonmap:'LAST_UPD_DATE',editable:false,hidden:true,
              editoptions :  {dataInit: function(element) {
                    $(element).datepicker({changeMonth : true,changeYear : true,dateFormat : 'yy-mm-dd'});
                }}  
            }     
        ],
        sortname:'DYNAMIC_ID',
        sortorder:'ASC',
        viewrecords : true,
        gridview : true,
        rownumbers : true,
        autowidth : true,
        rowNum : 20,
        rowList : [10,20,30],
        //onSelectRow:cellSelect,
        jsonReader : {
            page : "page.pageNo",
            total : "page.totalPages",
            records : "page.totalCount",
            root : "page.result",
            repeatitems : false,
            id : 'DYNAMIC_ID'
        },
        
        prmNames : {
            rows : "page.pageSize",
            page : "page.pageNo",
            sort : "page.orderBy",
            order : "page.order"
        },
        loadBeforeSend : function(xhr,settings){
            //设置访问的list标签
            settings.data=settings.data+ "&gridKey=/list/operation#TsmVoyageDynamic";
            return true;
        },
        pager : "#gridPager",
        caption : "航次动态列表"
    }).navGrid('#gridPager',{
            edit:true,
            //editfunc:cellSelect,
            //add:true, 
            addfunc:addVoyage,
            del:true, 
            //delfunc:selectDel,
            search: false
    },{ 
        //edit
        //beforeSubmit:cellSelect,
        reloadAfterSubmit:true,
        closeAfterEdit:true,//新增完毕后关闭
        afterComplete:opertaionPrompt,//更新结束后提示信息
        //onclickSubmit: fillCategoryId  //触发的事件
    },{
    //add
        reloadAfterSubmit : true,
        closeAfterAdd : true, //新增完毕后关闭
        afterComplete : opertaionPrompt,
        //onclickSubmit: fillCategoryId
    },{
      //del
        reloadAfterSubmit : true, 
        closeAfterEdit : true,  //修改完毕后关闭
        afterComplete : opertaionPrompt, //更新结束后提示信息
        //onclickSubmit: fillCategoryId,    
        
    })
    
});
var addVoyage=function(){
    var treeObj=$.fn.zTree.getZTreeObj("shipTree");
    //alert(treeObj);
      var nodes=treeObj.getSelectedNodes();
    //alert(nodes);
    var a=nodes[0].name;
    alert(a);
    
    
}
        
        
</#macro>
<#macro main>
	<div class="leftMaindiv">
  		<div id="treediv" class="ui-widget-content ui-corner-all">
           	<ul id="shipTree" class="ztree"></ul>
	  	</div>
  	</div>
  	<div class="rightdetaildiv">
       	<table id="gridTable"></table>
       	<div id="gridPager"></div>
  	</div>
</#macro>
        
        
        
        
        